/*!
 * \file rdmaxcliquer.c
 *
 * \date Jan 01, 2014
 * \author Ricardo C. Corrêa (correa@lia.ufc.br)
 *
 * \brief Ostergard's Russian doll algorithm for maximum clique.
 */

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/time.h>
#include <cliquer.h>

int main(int argc, char *argv[]) {
	FILE* outFile = NULL;

	outFile = fopen(argv[1], "a+");

	graph_t *g;
	set_t s;
	g = graph_read_dimacs_file(argv[2]);
	if (g == NULL)
		return 1;

	struct timespec start, end;
	struct timeval tvs, tve;
	float totalTime;

	gettimeofday(&tvs, NULL);
	clique_default_options->time_function = NULL;
	s = clique_unweighted_find_single(g, 0, 0, FALSE, NULL);
	gettimeofday(&tve, NULL);
	start.tv_sec = tvs.tv_sec;
	start.tv_nsec = tvs.tv_usec * 1000;
	end.tv_sec = tve.tv_sec;
	end.tv_nsec = tve.tv_usec * 1000;
	totalTime = (end.tv_sec - start.tv_sec);
	totalTime += (end.tv_nsec - start.tv_nsec) / 1000000000.0;

	set_print(s);

	printf("%s \t n=%d  time=%f\n", argv[2], g->n, totalTime);
	fprintf(outFile, "%s \t %d\t %f\n", argv[2], g->n, totalTime);
	fclose(outFile);

	return 0;
}
